%div#modal_merge_info.modal.hide
  .modal-dialog
    .modal-content
      .modal-header
        %a.close{href: "#", "data-dismiss" => "modal"} ×
        %h3 How to merge
      .modal-body
        - if @merge_request.for_fork?
          - source_remote = @merge_request.source_project.namespace.nil? ? "source" :@merge_request.source_project.namespace.path
          - target_remote = @merge_request.target_project.namespace.nil? ? "target" :@merge_request.target_project.namespace.path
          %p
            %strong Step 1.
            Fetch the code and create a new branch pointing to it
          %pre.dark
            :preserve
              git fetch #{@merge_request.source_project.http_url_to_repo} #{@merge_request.source_branch}
              git checkout -b #{@merge_request.source_project_path}-#{@merge_request.source_branch} FETCH_HEAD
          %p
            %strong Step 2.
            Merge the branch and push the changes to GitLab
          %pre.dark
            :preserve
              git checkout #{@merge_request.target_branch}
              git merge --no-ff #{@merge_request.source_project_path}-#{@merge_request.source_branch}
              git push origin #{@merge_request.target_branch}
        - else
          %p
            %strong Step 1.
            Update the repo and checkout the branch we are going to merge
          %pre.dark
            :preserve
              git fetch origin
              git checkout -b #{@merge_request.source_branch} origin/#{@merge_request.source_branch}
          %p
            %strong Step 2.
            Merge the branch and push the changes to GitLab
          %pre.dark
            :preserve
              git checkout #{@merge_request.target_branch}
              git merge --no-ff #{@merge_request.source_branch}
              git push origin #{@merge_request.target_branch}


:javascript
  $(function(){
    var modal = $('#modal_merge_info').modal({modal: true, show:false});
    $('.how_to_merge_link').bind("click", function(){
      modal.show();
    });
    $('.modal-header .close').bind("click", function(){
      modal.hide();
    })
  })
